package top.xin1901.j2ecd.common.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import top.xin1901.j2ecd.common.response.R;

/**
 * @author HeYunjia
 */

@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 捕获所有异常
     * @param e Exception 捕获的异常
     * @return R 返回异常请求信息
     */
    @ExceptionHandler(Exception.class)
    public R exceptionHandler(Exception e) {
        return R.exception().add("exception", e.getMessage());
    }
}
